const path = require('path')
const vuxLoader = require('vux-loader')
const webpack = require('webpack')
const {
	resolve
} = require('path')
const env = require('./env')
module.exports = {
	env: {
		universityAPI: env[process.env.MODE].ENV_UNIVERSITY_API,
	},	
	head: {
		title: '升学在线 - 高校管理中心',
		meta: [{
				charset: 'utf-8'
			},
			{
				name: "referrer",
				content: "no-referrer"
			},
			{
				name: 'format-detection',
				content: 'telephone=yes'
			},
			{
				name: 'viewport',
				content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no'
			},
			{
				hid: 'description',
				name: 'description',
				content: '{{escape description }}'
			}
		],
		link: [{
			rel: 'icon',
			type: 'image/x-icon',
			href: '/favicon.ico'
		}],
		script: [{
			innerHTML: "document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + `px`;",
			type: 'text/javascript'
		}]
	},
	router: {
		base: '/university-wechat/',
		mode: 'hash'
	},
	loading: {
		color: '#3B8070'
	},
	plugins: [{
			src: '~plugins/axios',
			ssr: false
		},
		{
			src: '~/plugins/global',
			ssr: false
		},
		{
			src: '~/plugins/vux-plugins',
			ssr: false
		},
		{
			src: '~/plugins/filter',
			ssr: false
		},
		{
			src:'~/plugins/echarts',
			ssr: false
		}
	],
	build: {
		uglify: {
			uglifyOptions: {
				mangle: {
					safari10: true
				}
			}
		},
		extend(config, {
			isDev,
			isClient
		}) {
			if (isDev && isClient) {
				config.module.rules.push({
					enforce: 'pre',
					test: /\.(js|vue)$/,
					loader: 'eslint-loader',
					exclude: /(node_modules)/
				})
			}
			const configs = vuxLoader.merge(config, {
				options: {
					ssr: true
				},
				plugins: ['vux-ui', {
					name: 'less-theme',
					path: path.join(__dirname, './styles/theme.less')
				}]
			})
			return configs
		},
	},
	modules: [
		'@nuxtjs/axios',
		'@nuxtjs/proxy'
	],
	/*
	 ** proxy
	 */
	proxy: {
		'/schoolApi': {
			// target: 'https://app.shengxue985.com',
			target: env[process.env.MODE].ENV_UNIVERSITY_API,
			changeOrigin: true,
			pathRewrite: {
				'^/schoolApi': 'api'
			}
		}
	},
	css: [
		'assets/css/main.css'
	],
}
